home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / progutil / iostream.zoo / src / igetline.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1991-09-22  |  1.4 KB  |  48 lines

  1. //    This is part of the iostream library, providing input/output for C++.
  2. //    Copyright (C) 1991 Per Bothner.
  3. //
  4. //    This library is free software; you can redistribute it and/or
  5. //    modify it under the terms of the GNU Library General Public
  6. //    License as published by the Free Software Foundation; either
  7. //    version 2 of the License, or (at your option) any later version.
  8. //
  9. //    This library is distributed in the hope that it will be useful,
  10. //    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. //    Library General Public License for more details.
  13. //
  14. //    You should have received a copy of the GNU Library General Public
  15. //    License along with this library; if not, write to the Free
  16. //    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18. #include "iostream.h"
  19.  
  20. istream& istream::getline(char* buf, int len, char delim = '\n')
  21. {
  22.     if (ipfx1()) {
  23.     long count = rdbuf()->sgetline(buf, len, delim, 0);
  24.     if (count < 0) {
  25.         clear(rdstate()|ios::failbit);
  26.         _gcount = 0;
  27.     }
  28.     else
  29.         _gcount = count;
  30.     }
  31.     return *this;
  32. }
  33.  
  34. istream& istream::get(char* buf, int len, char delim = '\n')
  35. {
  36.     if (ipfx1()) {
  37.     long count = rdbuf()->sgetline(buf, len, delim, -1);
  38.     if (count < 0) {
  39.         clear(rdstate()|ios::failbit);
  40.         _gcount = 0;
  41.     }
  42.     else
  43.         _gcount = count;
  44.     }
  45.     return *this;
  46. }
  47.  
  48.